<?php
class DakaModel extends Model{
	private $daka_id;
	private $user_id;
	private $time_id;
	private $add_time;
	private $flag;
	public function __set($n,$v){
		$this->$n=$v;
	}
	//打卡
	public function insert(){
		$time=time();
		$h=date('H');
		$riqi=date('Y-m-d',$time);
	    $sql="select flag from time where min_time<={$h} and max_time>={$h}";
	    $res=$this->db->_query($sql); 
	    $flag=$this->db->getRow();
        $flag=$flag['flag'];
		$query="insert into daka values (null,{$this->user_id},{$flag},{$time},'{$riqi}')";
		return $this->db->_query($query);
	}
	//查询个人打卡记录
	public function search(){//user_id={$this->user_id}
		$query="select * from daka where user_id={$this->user_id}";
		
		$this->db->_query($query);
		$rows=$this->db->getAll();
		return $rows;
	}
	//查询打卡记录
	public function searchAll(){
		$query="select u.user_id,u.user_name,d.* from daka_user u left join daka d on u.user_id=d.user_id";
		$this->db->_query($query);
		$rows=$this->db->getAll();
		return $rows;
	}
}












